<template>
  <div>
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="trainerQuery.name" placeholder="讲师名"/>
      </el-form-item>
      <el-form-item label="添加时间">
        <el-date-picker
          v-model="trainerQuery.createTime"
          type="datetime"
          placeholder="选择开始时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"/>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="trainerQuery.endTime"
          type="datetime"
          placeholder="选择截止时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"/>
      </el-form-item>

      <el-button type="primary" icon="el-icon-search" @click="getTrainerPageQuery">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>
    <!-- 表格 -->
    <el-table ref="trainersTable" :data="trainers" highlight-current-row fit @selection-change="selectChange">
      <el-table-column
        type="selection"
        width="55"/>
      <el-table-column
        label="序号"
        width="70">
        <template slot-scope="scope">
          <!-- 插值表单式计算每页数据的序号 -->
          {{ (current - 1) * size + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="name" label="名称" width="80" />

      <el-table-column label="头衔" width="80">
        <template slot-scope="scope">
          {{ scope.row.level===1?'高级讲师':'首席讲师' }}
        </template>
      </el-table-column>

      <el-table-column label="资历">
        <template slot-scope="scope">
          <div v-html="scope.row.intro"></div>
        </template>
      </el-table-column>
      <el-table-column label="图片">
        <template slot-scope="scope">
          <div class="demo-image">
            <img :src="minioBasePath+scope.row.avatar" style="height: 50px;width: 50px">
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="添加时间" width="160"/>

      <el-table-column label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" icon="el-icon-edit" @click="updateById(scope.row)">修改</el-button>
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="deleteById(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div style="height: 20px"></div>
    <div style="margin: auto;width: 500px">
      <div style="margin: auto;width: 300px">
        <el-button @click="toggleSelection()">取消选择</el-button>
        <el-button class="delete" type="delete" @click="allDelete()">全部删除</el-button>
      </div>
      <!-- 分页 -->
      <p/>
      <el-pagination
        :current-page="current"
        :page-sizes="[2, 5, 10, 20]"
        :page-size="size"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"/>
    </div>
  </div>
</template>

<script>
    export default {
        name: "list",
      data() {
        return {
          current: 1, // 当前页
          size: 5, // 页大小
          trainerQuery: {}, // 查询条件
          trainers: [], // 当前页数据
          total: 0, // 总记录
          selectChangeValue: [],
          minioBasePath:""
        }
      },
      created() {

      },
      methods: {

      }
    }
</script>

<style scoped>

</style>
